package facade;

import bean.Amigos;
import bean.Cadastro;
import bean.Perfil;
import bean.User;
import exceptions.AttributeNotRequirements;
import exceptions.CallNotAccepted;
import exceptions.CanNotAddYourself;
import exceptions.InvalidLogin;
import exceptions.InvalidPassword;
import exceptions.PersonNotFound;
import exceptions.SameUserLogin;
import exceptions.SizePassword;
import exceptions.UserIsAlreadyFriend;
import interfaces.IFacade;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Juliana Nóbrega - juliana@ffm.com.br
 */

public class Facade implements IFacade {

    private Cadastro cadastro;
    private Amigos amigos;
    private Perfil perfil;

    @Override
    public void addUser(String login, String name, String password) throws SameUserLogin, InvalidLogin, SizePassword {
        this.cadastro.addUser(login, name, password);
    }

    @Override
    public void editProfile(String description, String hometown, String marital, Date birthday) throws AttributeNotRequirements, InvalidLogin, InvalidPassword {
        try {
            this.perfil.editProfile(description, hometown, marital, birthday);
        } catch (ParseException ex) {
            Logger.getLogger(Facade.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void accessSystem(String login, String senha) throws InvalidLogin, InvalidPassword {
        this.amigos.accessSystem(login, senha);
        this.perfil.accessSystem(login, senha);
    }

    @Override
    public void addFriend(User user2) throws PersonNotFound, CallNotAccepted, UserIsAlreadyFriend, CanNotAddYourself {
        this.amigos.addFriend(user2);
    }

    @Override
    public void removeFriend() throws PersonNotFound {
        this.amigos.removeFriend();
    }
}
